//
//  XDShareView.m
//  XDCommonApp
//
//  Created by XD-XY on 3/15/14.
//  Copyright (c) 2014 XD-XY. All rights reserved.
//

#import "XDShareView.h"
#import "XDTools.h"
#import "XDHeader.h"

@implementation XDShareView

- (id)initWithFrame:(CGRect)frame
{
    self = [super initWithFrame:frame];
    if (self) {
        // Initialization code
        
        [self makeView];
    }
    return self;
}

-(void)makeView
{
    [self setBackgroundColor:[UIColor greenColor]];
    
    self.wxShareBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    _wxShareBtn.frame = CGRectMake(133/2.0f, 315/2.0f,98/2.0f,80/2.0f);
    [_wxShareBtn setImage:[UIImage imageNamed:@"wxshareimg"] forState:UIControlStateNormal];
    [_wxShareBtn addTarget:self action:@selector(shareBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    _wxShareBtn.backgroundColor = [UIColor clearColor];
    _wxShareBtn.tag = SHAREBTNTAG;
    
    [self addSubview:_wxShareBtn];
    
    UILabel * label1 = [[UILabel alloc] initWithFrame:CGRectMake(129/2.0f, height_y(_wxShareBtn)+23/2.0f, 50, 12)];
    label1.backgroundColor = [UIColor clearColor];
    label1.textColor = TEXTBLACKCOLORE4;
    label1.text = @"微信会话";
    label1.font = [UIFont systemFontOfSize:12];
    [self addSubview:label1];
    
    self.pyShareBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    _pyShareBtn.frame = CGRectMake(width_x(_wxShareBtn)+172/2.0f, _wxShareBtn.frame.origin.y, 80/2, 80/2);
    [_pyShareBtn setImage:[UIImage imageNamed:@"pyshareimg"] forState:UIControlStateNormal];
    [_pyShareBtn addTarget:self action:@selector(shareBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    _pyShareBtn.backgroundColor = [UIColor clearColor];
    _pyShareBtn.tag = SHAREBTNTAG+1;
    
    [self addSubview:_pyShareBtn];
    
    UILabel * label2 = [[UILabel alloc] initWithFrame:CGRectMake(380/2.0f, height_y(_wxShareBtn)+23/2.0f,70, 12)];
    label2.backgroundColor = [UIColor clearColor];
    label2.textColor = TEXTBLACKCOLORE4;
    label2.text = @"朋友圈分享";
    label2.font = [UIFont systemFontOfSize:12];
    [self addSubview:label2];
    
    self.xlShareBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    _xlShareBtn.frame = CGRectMake(129/2.0f, 179/2.0f+height_y(_wxShareBtn), 100/2, 80/2);
    [_xlShareBtn setImage:[UIImage imageNamed:@"xlshareimg"] forState:UIControlStateNormal];
    [_xlShareBtn addTarget:self action:@selector(shareBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    _xlShareBtn.backgroundColor = [UIColor clearColor];
    _xlShareBtn.tag = SHAREBTNTAG+2;
    
    [self addSubview:_xlShareBtn];
    
    UILabel * label3 = [[UILabel alloc] initWithFrame:CGRectMake(128/2.0f, height_y(_xlShareBtn)+30/2.0f, 50, 12)];
    label3.backgroundColor = [UIColor clearColor];
    label3.textColor = TEXTBLACKCOLORE4;
    label3.text = @"新浪微博";
    label3.font = [UIFont systemFontOfSize:12];
    [self addSubview:label3];
    
    self.copyeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    _copyeBtn.frame = CGRectMake(width_x(_xlShareBtn)+176/2.0f,height_y(_pyShareBtn)+176/2.0f, 76/2.0f, 88/2.0f);
    [_copyeBtn setImage:[UIImage imageNamed:@"copyimg"] forState:UIControlStateNormal];
    _copyeBtn.backgroundColor = [UIColor clearColor];
    [_copyeBtn addTarget:self action:@selector(shareBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    _copyeBtn.tag = SHAREBTNTAG+3;
    [self addSubview:_copyeBtn];
    
    UILabel * label4 = [[UILabel alloc] initWithFrame:CGRectMake(368/2.0f, height_y(_xlShareBtn)+30/2.0f, 80, 12)];
    label4.backgroundColor = [UIColor clearColor];
    label4.textColor = TEXTBLACKCOLORE4;
    label4.text = @"复制链接地址";
    label4.font = [UIFont systemFontOfSize:12];
    [self addSubview:label4];
    
    self.closeBtn = [UIButton buttonWithType:UIButtonTypeCustom];
    _closeBtn.frame = CGRectMake(160-29, UI_MAINSCREEN_HEIGHT-58-5, 58, 58);
    _closeBtn.backgroundColor = [UIColor clearColor];
    [_closeBtn setImage:[UIImage imageNamed:@"closeimg"] forState:UIControlStateNormal];
    [_closeBtn addTarget: self action:@selector(shareBtnClick:) forControlEvents:UIControlEventTouchUpInside];
    _closeBtn.tag = SHAREBTNTAG+4;
    [self addSubview:_closeBtn];
}

-(void)shareBtnClick:(UIButton *)sender
{
    [_delegate shareViewBtnCLick:sender];
}

/*
// Only override drawRect: if you perform custom drawing.
// An empty implementation adversely affects performance during animation.
- (void)drawRect:(CGRect)rect
{
    // Drawing code
}
*/

@end
